import { homeConfig } from '@/router/homeConfig.js'
import { createRouter, createWebHistory } from 'vue-router'
import { routerGuard } from './guard.js'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'layout',
      redirect: '/lingTach',
    },
    {
      path: '/lingTach',
      name: 'lingTach',
      component: () => import('@/views/layout.vue'),
      redirect: '/lingTach/home',
      children: homeConfig,
    },
  ],
})

// 安装vue路由
export async function installRouter(app) {
  // 添加路由guard
  routerGuard(router)
  app.use(router)
  await router.isReady()
}
export default router
